const mongoose = require('mongoose')
const Content = require('../../model/content')
const Reply = require('../../model/reply')
const Normal = require('../../model/normal')
module.exports =async (id)=>{
    const data = await Reply.findOne({ _id: id }).select('author -_id')
    var b = await Reply.deleteOne({ _id: id })
    const c = await Content.updateOne({ child: { $in: [id] } }, { $pull: { child: id } })
    var author = data.author
    var num1 = await Content.find({author}).count()
    var num2 = await Reply.find({$or:[
        {author},{reply:author}
    ]}).count()
    if(num1==0&&num2==0){
        const d = await Normal.deleteOne({ _id: author, type: 'user' })
    }
}